package com.wsclient1;

import cn.edu.usts.service.serviceImpl.UserServiceImpl;
import com.wsclient1.pojo.User;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;

public class test {


    public static void main(String[] args) throws MalformedURLException {
            System.setProperty("javax.xml.bind.JAXBContext", "com.sun.xml.internal.bind.v2.ContextFactory");
            URL url = new URL("http://localhost:8081/ws/userService?wsdl");
            // 指定命名空间和服务名称
            QName qName = new QName("http://serviceImpl.service.usts.edu.cn/", "UserServiceImplService");
            Service service = Service.create(url, qName);
            UserServiceImpl port = service.getPort(UserServiceImpl.class);

            User user1 = port.queryUser(1);


        // 通过getPort方法返回指定接口
//           UserServiceImpl myServer = service.getPort(
//                    new QName("http://serviceImpl.service.wsserver1.com/", "UserServiceImplPort"), // 绑定端口名称
//                   UserServiceImpl.class);
            // 调用方法 获取返回值
//        UserServiceImplPort userServiceImplPort = service.getPort(UserServiceImplPort.class);
//        User user = userServiceImplPort.queryUser(1);
//        User user = myServer.queryUser(1);

//            User user = myServer.queryUser(1);
//            System.out.println(user1.toString());
        }
    }
